package com.zpark;

import java.util.Scanner;

/**
 * 完美立方
 * 书P36-38
 */
public class PerfectCube {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入大于1的，不大于100的正整数");
        int n = scan.nextInt();
        // 枚举完美立方等式四个数用的变量
        int a, b, c, d;
        // 为了方便后续的代码执行，将2-100的立方存储起来
        int[] cube = new int[n + 1];
        for (int i = 2; i <= n; i++)
            cube[i] = (int) Math.pow(i, 3);
        // 开始枚举
        for (a = 6; a <= n; a++) {              // 枚举a
            for (b = 2; b < a; b++) {           //枚举b
                for (c = b; c < a; c++) {       //枚举c
                    for (d = c; d < a; d++) {    //枚举d
                        if (cube[a] == cube[b] + cube[c] + cube[d])
                            System.out.printf("Cube = %d, Triple = (%d, %d, %d)\r\n", a, b, c, d);

                    }
                }
            }
        }
    }
}